clear all
close all
clc
%Detect objects using Viola-Jones Algorithm

addpath('./test');
seqData = dir('./test/*.jpg');
seqNum  = size(seqData,1);

%To detect Face
FDetect = vision.CascadeObjectDetector;

figure;
for iSeqNum = 1:seqNum
    clf;
    I = imread(seqData(iSeqNum).name);
    imshow(I);
    hold on
    BB = step(FDetect,I);
    for i = 1:size(BB,1)
        rectangle('Position',BB(i,:),'LineWidth',5,'LineStyle','-','EdgeColor','r');
    end
    title('Face Detection');
    hold off;
    pause;
end

% %Read the input image
% I = imread('2.jpg');

%Returns Bounding Box values based on number of objects
BB = step(FDetect,I);

figure,
imshow(I); hold on
for i = 1:size(BB,1)
    rectangle('Position',BB(i,:),'LineWidth',5,'LineStyle','-','EdgeColor','r');
end
title('Face Detection');
hold off;